import 'package:base_flutter/base_flutter.dart';
import 'package:base_flutter/src/utils/ext_utils.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class TitleValueWidget extends StatelessWidget {
  final String name;
  final Color color;
  final bool showArrow;
  final bool isRequired;
  String text;
  String hint;
  EdgeInsets padding;
  TextAlign textAlign;
  Widget? rightWeight;

  TitleValueWidget(this.name,
      {this.color = Colors.white,
      this.showArrow = true,
      this.isRequired = false,
      this.text = "",
      this.hint = "请选择",
      this.padding = const EdgeInsets.symmetric(horizontal: 16, vertical: 13),
      this.textAlign = TextAlign.start,this.rightWeight});

  @override
  Widget build(BuildContext context) {
    return Row(
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        isRequired
            ? Text.rich(TextSpan(
                text: "*",
                style: TextStyle(color: Colors.red, fontSize: 16),
                children: [
                    TextSpan(
                      text: name,
                      style: TextStyle(color: Colors.black, fontSize: 16),
                    )
                  ])).setWeight(2)
            : Text(
                name,
                textAlign: TextAlign.start,
                style: TextStyle(color: Colors.black, fontSize: 16),
              ).setWeight(2),
        CommonText(text,
                hintText: hint, textSize: 16, textColor: Color(0xff646668),textAlign: textAlign)
            .setWeight(3),
        showArrow
            ? this.rightWeight??Icon(
                Icons.arrow_forward_ios_rounded,
                size: 15,
                color: Colors.grey,
              )
            : Container()
      ],
    ).addToContainer(
        color: color,
        padding: padding);
  }
}
